Operators in Kotlin, such as / for division, map to functions. / maps to div(), for example. We can implement those functions on whatever types we want (directly or via extension functions), and then we can use the operator for those types. However, we have to add the operator keyword to the function declaration, which works a bit like override and indicates that we know that we are implementing a function that is tied to an operator.

Here, we implement div() on String, to be able to divide a string into a certain number of pieces.

You can learn more about this in:
Tags:
Run Edit